<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');
$adm_functions->is_admin_login();

$adm_menu='
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="menudottedline" width="40%">
			<div class="pathway"><img src="assets/admin/'.$SITE_LOGO_ADMIN.'"/></div>	</td>
		<td class="menudottedline" align="right">
			<table cellpadding="0" cellspacing="0" border="0" id="toolbar">
				<tr valign="middle" align="center">
					<td>&nbsp;</td>
					<td>
					<a class="toolbar" href="javascript:kliksubmit();">
						<img src="show_files/save.png"  alt="Save" name="save" title="Save" align="middle" border="0" />				<br />Save</a>
					</td>
					<td>&nbsp;</td>
					<td>
						<a class="toolbar" href="admin.php?show=user_manager">
						<img src="show_files/cancel.png"  alt="Cancel" name="cancel" title="Cancel" align="middle" border="0" />				<br />Cancel</a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<br />
';
		$val_username=''; 
		$val_password='';
		$val_password2='';
		$val_select1='selected';
		$val_select2='';
		$val_select3='';
		$val_select4='selected';
		$val_name='';
		$val_birth='';
		$val_company='';
		$val_address='';
		$val_zip='';
		$val_city='';
		$val_country='';
		$val_email='';
		$val_telp='';
		$val_fax='';
		$section='Add New User';

if($inp_username)
{
	$qry="select * from anggota where username='$inp_username'";
	$TOTAL_RECORDSET=$dbh->num_rows($dbh->query($qry));
	$qry1="select * from anggota where email='$inp_email'";
	$TOTAL_RECORDSET1=$dbh->num_rows($dbh->query($qry1));
	if ($TOTAL_RECORDSET>0) $error_message='Username already exist ';
	if ($TOTAL_RECORDSET1>0) $error_message.='Email already exist';
	if ($TOTAL_RECORDSET>0 || $TOTAL_RECORDSET1>0) {
		$val_username=$inp_username; 
		$val_password=$inp_password;
		$val_password2=$inp_password;
		if ($inp_active=='Y') 
		{
			$val_select1='selected';
			$val_select2='';
		}
			else 
		{
				$val_select1='';
				$val_select2='selected';
		}
		if ($inp_suspend=='Y') 
		{
			$val_select3='selected'; 
			$val_select4=''; 
		}
			else 
		{
			$val_select3=''; 
			$val_select4='selected'; 
		}
//		$val_select2='';
//		$val_select3='';
//		$val_select4='selected';
		$val_name=$inp_name;
		$val_birth=$inp_birth;
		$val_company=$inp_company;
		$val_address=$inp_address;
		$val_zip=$inp_zip;
		$val_city=$inp_city;
		$val_country=$inp_country;
		$val_email=$inp_email;
		$val_telp=$inp_telp;
		$val_fax=$inp_fax;
		$section='Add New User';
	} else 
	{
	$dbh->query("insert into anggota (
	username, 
	password,
	nama,
	active,
	suspend,
	tanggal,
	perus,
	alamat1,
	zipcode,
	kota,
	negara,
	email,
	telp,
	fax) values (
	'$inp_username', 
	'$inp_password',
	'$inp_name',
	'$inp_active',
	'$inp_suspend',
	'$inp_birth',
	'$inp_company',
	'$inp_address',
	'$inp_zip',
	'$inp_city',
	'$inp_country',
	'$inp_email',
	'$inp_telp',
	'$inp_fax')");
	echo '<script>alert("Added New User");</script>';
	echo '<script>window.location.href="admin.php?show=user_manager";</script>';
	}
}

?>